﻿namespace Innovative.ProXr
{
	/// <summary>
	/// Converts an API that responds with a single byte value
	/// to an integer.
	/// </summary>
	public class Int32ArrayResponseConverter : IResponseConverter<int[]>
	{
		int[] IResponseConverter<int[]>.Convert(RelayByte[] response)
		{
			int[] returnValue = new int[response.Length];

			if (response.Length > 0)
			{
				foreach (RelayByte item in response)
				{
					returnValue[0] = (int)item;
				}
			}
			else
			{
				throw new InvalidResponseException("The Int32ResponseConverter converter expects one or more bytes in the response.");
			}

			return returnValue;
		}
	}
}
